home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / WINPROGS / WINSRC20.ZIP / DIALOG2.C < prev    next >
C/C++ Source or Header  |  1990-10-20  |  40KB  |  1,176 lines

  1. /*
  2.  
  3.     various dialog-box code - more in DIALOG.C
  4.  
  5. */
  6.  
  7. #include "windows.h"
  8. #include "winfract.h"
  9. #include "fractint.h"
  10. #include <math.h>
  11. #include <stdio.h>
  12.  
  13. extern HWND hwnd;                               /* handle to main window */
  14. extern char szHelpFileName[];                   /* Help file name*/
  15.  
  16. extern BOOL zoomflag;                /* TRUE is a zoom-box selected */
  17.  
  18. extern char *win_choices[];
  19. extern int win_numchoices, win_choicemade;
  20. int CurrentFractal;
  21.  
  22. extern HANDLE hDibInfo;        /* handle to the Device-independent bitmap */
  23. extern LPBITMAPINFO pDibInfo;        /* pointer to the DIB info */
  24.  
  25. extern int time_to_restart;                               /* time to restart?  */
  26. extern int time_to_reinit;                /* time to reinit? */
  27. extern int time_to_cycle;                               /* time to cycle? */
  28.  
  29. extern int xdots, ydots, colors, maxiter;
  30. extern int ytop, ybottom, xleft, xright;
  31. extern double xxmin, xxmax, yymin, yymax;
  32. extern int fractype;
  33. extern int calc_status;
  34. extern double param[4];
  35.  
  36. extern int inside, outside, biomorph, decomp, debugflag;
  37. extern int usr_stdcalcmode, usr_floatflag;
  38. extern    int    invert;     /* non-zero if inversion active */
  39. extern    double    inversion[3];    /* radius, xcenter, ycenter */
  40.  
  41. int tempfractype;
  42. int tempcolors;
  43. char tempstdcalcmode, tempfloatflag;
  44.  
  45. int numparams,numtrig;
  46. static char *trg[] = {"First Function","Second Function",
  47.               "Third Function","Fourth Function"};
  48. static int paramt[] = {ID_FRACPARTX1, ID_FRACPARTX2,
  49.                        ID_FRACPARTX3, ID_FRACPARTX4 };
  50. static int paramv[] = {ID_FRACPARAM1, ID_FRACPARAM2,
  51.                        ID_FRACPARAM3, ID_FRACPARAM4, };
  52.  
  53. extern int win_release;
  54. extern char win_comment[];
  55.  
  56. extern char DialogTitle[];
  57.  
  58. /****************************************************************************
  59.  
  60.     FUNCTION: About(HWND, unsigned, WORD, LONG)
  61.  
  62.     PURPOSE:  Processes messages for "About" dialog box
  63.  
  64.     MESSAGES:
  65.  
  66.         WM_INITDIALOG - initialize dialog box
  67.         WM_COMMAND    - Input received
  68.  
  69. ****************************************************************************/
  70.  
  71. BOOL FAR PASCAL About(hDlg, message, wParam, lParam)
  72. HWND hDlg;
  73. unsigned message;
  74. WORD wParam;
  75. LONG lParam;
  76. {
  77.  
  78. float temp;
  79. char tempname[40];
  80.  
  81.     switch (message) {
  82.  
  83.          case WM_KEYDOWN:
  84.              switch (wParam) {
  85.                  case VK_F1:
  86.                  /* F1, shifted F1 bring up the Help Index */
  87.                      WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  88.                      break;
  89.                  }
  90.  
  91.         case WM_INITDIALOG:
  92.             temp = win_release / 100.0;
  93.             sprintf(tempname,"Fractint for Windows - Vers %5.2f", temp);
  94.             SetDlgItemText(hDlg, ID_VERSION,tempname);
  95.             SetDlgItemText(hDlg, ID_COMMENT,win_comment);
  96.             return (TRUE);
  97.  
  98.         case WM_COMMAND:
  99.         if (wParam == IDOK
  100.                 || wParam == IDCANCEL) {
  101.                 EndDialog(hDlg, TRUE);
  102.                 return (TRUE);
  103.             }
  104.             break;
  105.     }
  106.     return (FALSE);
  107. }
  108.  
  109. /****************************************************************************
  110.  
  111.     FUNCTION: Status(HWND, unsigned, WORD, LONG)
  112.  
  113.     PURPOSE:  Processes messages for "Status" dialog box
  114.  
  115.     MESSAGES:
  116.  
  117.         WM_INITDIALOG - initialize dialog box
  118.         WM_COMMAND    - Input received
  119.  
  120. ****************************************************************************/
  121.  
  122. BOOL FAR PASCAL Status(hDlg, message, wParam, lParam)
  123. HWND hDlg;
  124. unsigned message;
  125. WORD wParam;
  126. LONG lParam;
  127. {
  128. char tempstring[100];
  129. int i, j;
  130.  
  131.     switch (message) {
  132.  
  133.         case WM_KEYDOWN:
  134.             switch (wParam) {
  135.                 case VK_F1:
  136.                 /* F1, shifted F1 bring up the Help Index */
  137.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  138.                     break;
  139.                 }
  140.  
  141.         case WM_INITDIALOG:
  142.             sprintf(tempstring,"fractal type: ");
  143.             strcat(tempstring, fractalspecific[fractype].name);
  144.             if (calc_status == 1)
  145.                 strcat(tempstring,"    (still being calculated)");
  146.             else
  147.                 strcat(tempstring,"    (interrupted/completed)");
  148.             /* ##### */
  149.             SetDlgItemText(hDlg, IDS_LINE1,tempstring);
  150.             if(fractalspecific[fractype].param[0][0] == 0)
  151.                 tempstring[0] = 0;
  152.             else
  153.                 sprintf(tempstring,"%-30.30s   %14.10f",
  154.                     fractalspecific[fractype].param[0], param[0]);
  155.             SetDlgItemText(hDlg, IDS_LINE2,tempstring);
  156.             if(fractalspecific[fractype].param[1][0] == 0)
  157.                 tempstring[0] = 0;
  158.             else
  159.                 sprintf(tempstring,"%-30.30s   %14.10f",
  160.                     fractalspecific[fractype].param[1], param[1]);
  161.             SetDlgItemText(hDlg, IDS_LINE3,tempstring);
  162.             if(fractalspecific[fractype].param[2][0] == 0)
  163.                 tempstring[0] = 0;
  164.             else
  165.                 sprintf(tempstring,"%-30.30s   %14.10f",
  166.                     fractalspecific[fractype].param[2], param[2]);
  167.             SetDlgItemText(hDlg, IDS_LINE4,tempstring);
  168.             if(fractalspecific[fractype].param[3][0] == 0)
  169.                 tempstring[0] = 0;
  170.             else
  171.                 sprintf(tempstring,"%-30.30s   %14.10f",
  172.                     fractalspecific[fractype].param[3], param[3]);
  173.             SetDlgItemText(hDlg, IDS_LINE5,tempstring);
  174.             sprintf(tempstring,"Xmin:        %25.16f", xxmin);
  175.             SetDlgItemText(hDlg, IDS_LINE6,tempstring);
  176.             sprintf(tempstring,"Xmax:        %25.16f", xxmax);
  177.             SetDlgItemText(hDlg, IDS_LINE7,tempstring);
  178.             sprintf(tempstring,"Ymin:        %25.16f", yymin);
  179.             SetDlgItemText(hDlg, IDS_LINE8,tempstring);
  180.             sprintf(tempstring,"Ymax:        %25.16f", yymax);
  181.             SetDlgItemText(hDlg, IDS_LINE9,tempstring);
  182.             return (TRUE);
  183.  
  184.         case WM_COMMAND:
  185.         if (wParam == IDOK
  186.                 || wParam == IDCANCEL) {
  187.                 EndDialog(hDlg, TRUE);
  188.                 return (TRUE);
  189.             }
  190.             break;
  191.     }
  192.     return (FALSE);
  193. }
  194.  
  195. /****************************************************************************
  196.  
  197.     FUNCTION: SelectFractal(HWND, unsigned, WORD, LONG)
  198.  
  199.     PURPOSE: Initializes window data and registers window class
  200.  
  201. ****************************************************************************/
  202.  
  203. BOOL FAR PASCAL SelectFractal(hDlg, message, wParam, lParam)
  204. HWND hDlg;
  205. unsigned message;
  206. WORD wParam;
  207. LONG lParam;
  208. {
  209.  
  210.     int i;
  211.     int index;
  212.  
  213.     switch (message) {
  214.  
  215.         case WM_KEYDOWN:
  216.             switch (wParam) {
  217.                 case VK_F1:
  218.                 /* F1, shifted F1 bring up the Help Index */
  219.                     WinHelp(hwnd,szHelpFileName,HELP_INDEX,0L);
  220.                     break;
  221.                 }
  222.  
  223.         case WM_INITDIALOG:
  224.             SetDlgItemText(hDlg, ID_LISTTITLE, DialogTitle);
  225.             for (i = 0; i < win_numchoices; i++) 
  226.                 SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_ADDSTRING,
  227.                     NULL, (LONG) (LPSTR) win_choices[i]);
  228.             SendDlgItemMessage(hDlg, IDM_FRACTAL, LB_SETCURSEL,
  229.                 win_choicemade, 0L);
  230.             return (TRUE);
  231.             break;
  232.         
  233.         case WM_COMMAND:
  234.             switch (wParam) {
  235.                 case IDOK:
  236. okay:           
  237.                     index=SendDlgItemMessage(hDlg, IDM_FRACTAL,
  238.                         LB_GETCURSEL, 0, 0L);
  239.                     if (index == LB_ERR) {
  240.                         MessageBox(hDlg, "No Choice selected",
  241.                             "Select From a List", MB_OK | MB_ICONEXCLAMATION);
  242.                         break;
  243.                         }
  244.                     win_choicemade = index;
  245.                     EndDialog(hDlg, 1);
  246.                     break;
  247.                   
  248.                 case IDCANCEL:
  249.                     win_choicemade = -1;
  250.                     EndDialog(hDlg, 0);
  251.                     break;